3.3.32 \(\int \tan ^2(c+d x) (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx\) [232]

3.3.32.1 Optimal result
3.3.32.2 Mathematica [A] (verified)
3.3.32.3 Rubi [A] (verified)
3.3.32.4 Maple [A] (verified)
3.3.32.5 Fricas [A] (verification not implemented)
3.3.32.6 Sympy [A] (verification not implemented)
3.3.32.7 Maxima [A] (verification not implemented)
3.3.32.8 Giac [B] (verification not implemented)
3.3.32.9 Mupad [B] (verification not implemented)

3.3.32.1 Optimal result

Integrand size = 29, antiderivative size = 87 \[ \int \tan ^2(c+d x) (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-((a A-b B) x)+\frac {(A b+a B) \log (\cos (c+d x))}{d}+\frac {(a A-b B) \tan (c+d x)}{d}+\frac {(A b+a B) \tan ^2(c+d x)}{2 d}+\frac {b B \tan ^3(c+d x)}{3 d} \]

output
-(A*a-B*b)*x+(A*b+B*a)*ln(cos(d*x+c))/d+(A*a-B*b)*tan(d*x+c)/d+1/2*(A*b+B* 
a)*tan(d*x+c)^2/d+1/3*b*B*tan(d*x+c)^3/d
 
3.3.32.2 Mathematica [A] (verified)

Time = 0.62 (sec) , antiderivative size = 86, normalized size of antiderivative = 0.99 \[ \int \tan ^2(c+d x) (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {(-6 a A+6 b B) \arctan (\tan (c+d x))+6 (A b+a B) \log (\cos (c+d x))+6 (a A-b B) \tan (c+d x)+3 (A b+a B) \tan ^2(c+d x)+2 b B \tan ^3(c+d x)}{6 d} \]

input
Integrate[Tan[c + d*x]^2*(a + b*Tan[c + d*x])*(A + B*Tan[c + d*x]),x]
 
output
((-6*a*A + 6*b*B)*ArcTan[Tan[c + d*x]] + 6*(A*b + a*B)*Log[Cos[c + d*x]] + 
 6*(a*A - b*B)*Tan[c + d*x] + 3*(A*b + a*B)*Tan[c + d*x]^2 + 2*b*B*Tan[c + 
 d*x]^3)/(6*d)
 
3.3.32.3 Rubi [A] (verified)

Time = 0.51 (sec) , antiderivative size = 87, normalized size of antiderivative = 1.00, number of steps used = 8, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.276, Rules used = {3042, 4075, 3042, 4011, 3042, 4008, 3042, 3956}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \tan ^2(c+d x) (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \tan (c+d x)^2 (a+b \tan (c+d x)) (A+B \tan (c+d x))dx\)

\(\Big \downarrow \) 4075

\(\displaystyle \int \tan ^2(c+d x) (a A-b B+(A b+a B) \tan (c+d x))dx+\frac {b B \tan ^3(c+d x)}{3 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \tan (c+d x)^2 (a A-b B+(A b+a B) \tan (c+d x))dx+\frac {b B \tan ^3(c+d x)}{3 d}\)

\(\Big \downarrow \) 4011

\(\displaystyle \int \tan (c+d x) (-A b-a B+(a A-b B) \tan (c+d x))dx+\frac {(a B+A b) \tan ^2(c+d x)}{2 d}+\frac {b B \tan ^3(c+d x)}{3 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \tan (c+d x) (-A b-a B+(a A-b B) \tan (c+d x))dx+\frac {(a B+A b) \tan ^2(c+d x)}{2 d}+\frac {b B \tan ^3(c+d x)}{3 d}\)

\(\Big \downarrow \) 4008

\(\displaystyle -(a B+A b) \int \tan (c+d x)dx+\frac {(a B+A b) \tan ^2(c+d x)}{2 d}+\frac {(a A-b B) \tan (c+d x)}{d}-x (a A-b B)+\frac {b B \tan ^3(c+d x)}{3 d}\)

\(\Big \downarrow \) 3042

\(\displaystyle -(a B+A b) \int \tan (c+d x)dx+\frac {(a B+A b) \tan ^2(c+d x)}{2 d}+\frac {(a A-b B) \tan (c+d x)}{d}-x (a A-b B)+\frac {b B \tan ^3(c+d x)}{3 d}\)

\(\Big \downarrow \) 3956

\(\displaystyle \frac {(a B+A b) \tan ^2(c+d x)}{2 d}+\frac {(a A-b B) \tan (c+d x)}{d}+\frac {(a B+A b) \log (\cos (c+d x))}{d}-x (a A-b B)+\frac {b B \tan ^3(c+d x)}{3 d}\)

input
Int[Tan[c + d*x]^2*(a + b*Tan[c + d*x])*(A + B*Tan[c + d*x]),x]
 
output
-((a*A - b*B)*x) + ((A*b + a*B)*Log[Cos[c + d*x]])/d + ((a*A - b*B)*Tan[c 
+ d*x])/d + ((A*b + a*B)*Tan[c + d*x]^2)/(2*d) + (b*B*Tan[c + d*x]^3)/(3*d 
)
 

3.3.32.3.1 Defintions of rubi rules used

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

rule 4008
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)]), x_Symbol] :> Simp[(a*c - b*d)*x, x] + (Simp[b*d*(Tan[e + f*x]/f), 
x] + Simp[(b*c + a*d)   Int[Tan[e + f*x], x], x]) /; FreeQ[{a, b, c, d, e, 
f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]
 

rule 4011
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)]), x_Symbol] :> Simp[d*((a + b*Tan[e + f*x])^m/(f*m)), x] + Int 
[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x], x] 
, x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 
 0] && GtQ[m, 0]
 

rule 4075
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) 
+ (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[B 
*d*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f* 
x])^m*Simp[A*c - B*d + (B*c + A*d)*Tan[e + f*x], x], x] /; FreeQ[{a, b, c, 
d, e, f, A, B, m}, x] && NeQ[b*c - a*d, 0] &&  !LeQ[m, -1]
 
3.3.32.4 Maple [A] (verified)

Time = 0.05 (sec) , antiderivative size = 88, normalized size of antiderivative = 1.01

method result size
norman \(\left (-a A +B b \right ) x +\frac {\left (a A -B b \right ) \tan \left (d x +c \right )}{d}+\frac {\left (A b +B a \right ) \left (\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {b B \left (\tan ^{3}\left (d x +c \right )\right )}{3 d}-\frac {\left (A b +B a \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(88\)
parts \(\frac {\left (A b +B a \right ) \left (\frac {\left (\tan ^{2}\left (d x +c \right )\right )}{2}-\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}\right )}{d}+\frac {B b \left (\frac {\left (\tan ^{3}\left (d x +c \right )\right )}{3}-\tan \left (d x +c \right )+\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}+\frac {a A \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(91\)
derivativedivides \(\frac {\frac {b B \left (\tan ^{3}\left (d x +c \right )\right )}{3}+\frac {A b \left (\tan ^{2}\left (d x +c \right )\right )}{2}+\frac {B \left (\tan ^{2}\left (d x +c \right )\right ) a}{2}+A \tan \left (d x +c \right ) a -b B \tan \left (d x +c \right )+\frac {\left (-A b -B a \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-a A +B b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(99\)
default \(\frac {\frac {b B \left (\tan ^{3}\left (d x +c \right )\right )}{3}+\frac {A b \left (\tan ^{2}\left (d x +c \right )\right )}{2}+\frac {B \left (\tan ^{2}\left (d x +c \right )\right ) a}{2}+A \tan \left (d x +c \right ) a -b B \tan \left (d x +c \right )+\frac {\left (-A b -B a \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-a A +B b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(99\)
parallelrisch \(-\frac {-2 b B \left (\tan ^{3}\left (d x +c \right )\right )+6 A x a d -3 A b \left (\tan ^{2}\left (d x +c \right )\right )-6 B b d x -3 B \left (\tan ^{2}\left (d x +c \right )\right ) a +3 A \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) b -6 A \tan \left (d x +c \right ) a +3 B \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a +6 b B \tan \left (d x +c \right )}{6 d}\) \(105\)
risch \(-i A b x -i B a x -A a x +B b x -\frac {2 i A b c}{d}-\frac {2 i a B c}{d}+\frac {2 i \left (-3 i A b \,{\mathrm e}^{4 i \left (d x +c \right )}-3 i B a \,{\mathrm e}^{4 i \left (d x +c \right )}+3 A a \,{\mathrm e}^{4 i \left (d x +c \right )}-6 B b \,{\mathrm e}^{4 i \left (d x +c \right )}-3 i A b \,{\mathrm e}^{2 i \left (d x +c \right )}-3 i B a \,{\mathrm e}^{2 i \left (d x +c \right )}+6 A a \,{\mathrm e}^{2 i \left (d x +c \right )}-6 B b \,{\mathrm e}^{2 i \left (d x +c \right )}+3 a A -4 B b \right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{3}}+\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) A b}{d}+\frac {a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B}{d}\) \(213\)

input
int(tan(d*x+c)^2*(a+b*tan(d*x+c))*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE 
)
 
output
(-A*a+B*b)*x+(A*a-B*b)*tan(d*x+c)/d+1/2*(A*b+B*a)*tan(d*x+c)^2/d+1/3*b*B*t 
an(d*x+c)^3/d-1/2*(A*b+B*a)/d*ln(1+tan(d*x+c)^2)
 
3.3.32.5 Fricas [A] (verification not implemented)

Time = 0.25 (sec) , antiderivative size = 85, normalized size of antiderivative = 0.98 \[ \int \tan ^2(c+d x) (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {2 \, B b \tan \left (d x + c\right )^{3} - 6 \, {\left (A a - B b\right )} d x + 3 \, {\left (B a + A b\right )} \tan \left (d x + c\right )^{2} + 3 \, {\left (B a + A b\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 6 \, {\left (A a - B b\right )} \tan \left (d x + c\right )}{6 \, d} \]

input
integrate(tan(d*x+c)^2*(a+b*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="fri 
cas")
 
output
1/6*(2*B*b*tan(d*x + c)^3 - 6*(A*a - B*b)*d*x + 3*(B*a + A*b)*tan(d*x + c) 
^2 + 3*(B*a + A*b)*log(1/(tan(d*x + c)^2 + 1)) + 6*(A*a - B*b)*tan(d*x + c 
))/d
 
3.3.32.6 Sympy [A] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 136, normalized size of antiderivative = 1.56 \[ \int \tan ^2(c+d x) (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\begin {cases} - A a x + \frac {A a \tan {\left (c + d x \right )}}{d} - \frac {A b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {A b \tan ^{2}{\left (c + d x \right )}}{2 d} - \frac {B a \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {B a \tan ^{2}{\left (c + d x \right )}}{2 d} + B b x + \frac {B b \tan ^{3}{\left (c + d x \right )}}{3 d} - \frac {B b \tan {\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \left (A + B \tan {\left (c \right )}\right ) \left (a + b \tan {\left (c \right )}\right ) \tan ^{2}{\left (c \right )} & \text {otherwise} \end {cases} \]

input
integrate(tan(d*x+c)**2*(a+b*tan(d*x+c))*(A+B*tan(d*x+c)),x)
 
output
Piecewise((-A*a*x + A*a*tan(c + d*x)/d - A*b*log(tan(c + d*x)**2 + 1)/(2*d 
) + A*b*tan(c + d*x)**2/(2*d) - B*a*log(tan(c + d*x)**2 + 1)/(2*d) + B*a*t 
an(c + d*x)**2/(2*d) + B*b*x + B*b*tan(c + d*x)**3/(3*d) - B*b*tan(c + d*x 
)/d, Ne(d, 0)), (x*(A + B*tan(c))*(a + b*tan(c))*tan(c)**2, True))
 
3.3.32.7 Maxima [A] (verification not implemented)

Time = 0.37 (sec) , antiderivative size = 86, normalized size of antiderivative = 0.99 \[ \int \tan ^2(c+d x) (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {2 \, B b \tan \left (d x + c\right )^{3} + 3 \, {\left (B a + A b\right )} \tan \left (d x + c\right )^{2} - 6 \, {\left (A a - B b\right )} {\left (d x + c\right )} - 3 \, {\left (B a + A b\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 6 \, {\left (A a - B b\right )} \tan \left (d x + c\right )}{6 \, d} \]

input
integrate(tan(d*x+c)^2*(a+b*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="max 
ima")
 
output
1/6*(2*B*b*tan(d*x + c)^3 + 3*(B*a + A*b)*tan(d*x + c)^2 - 6*(A*a - B*b)*( 
d*x + c) - 3*(B*a + A*b)*log(tan(d*x + c)^2 + 1) + 6*(A*a - B*b)*tan(d*x + 
 c))/d
 
3.3.32.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 937 vs. \(2 (83) = 166\).

Time = 0.85 (sec) , antiderivative size = 937, normalized size of antiderivative = 10.77 \[ \int \tan ^2(c+d x) (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\text {Too large to display} \]

input
integrate(tan(d*x+c)^2*(a+b*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="gia 
c")
 
output
-1/6*(6*A*a*d*x*tan(d*x)^3*tan(c)^3 - 6*B*b*d*x*tan(d*x)^3*tan(c)^3 - 3*B* 
a*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 
 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^3*tan(c)^3 - 3*A*b*log(4*(tan(d*x) 
^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + t 
an(c)^2 + 1))*tan(d*x)^3*tan(c)^3 - 18*A*a*d*x*tan(d*x)^2*tan(c)^2 + 18*B* 
b*d*x*tan(d*x)^2*tan(c)^2 - 3*B*a*tan(d*x)^3*tan(c)^3 - 3*A*b*tan(d*x)^3*t 
an(c)^3 + 9*B*a*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d 
*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^2*tan(c)^2 + 9*A*b*l 
og(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + 
tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)^2*tan(c)^2 + 6*A*a*tan(d*x)^3*tan(c)^ 
2 - 6*B*b*tan(d*x)^3*tan(c)^2 + 6*A*a*tan(d*x)^2*tan(c)^3 - 6*B*b*tan(d*x) 
^2*tan(c)^3 + 18*A*a*d*x*tan(d*x)*tan(c) - 18*B*b*d*x*tan(d*x)*tan(c) - 3* 
B*a*tan(d*x)^3*tan(c) - 3*A*b*tan(d*x)^3*tan(c) + 3*B*a*tan(d*x)^2*tan(c)^ 
2 + 3*A*b*tan(d*x)^2*tan(c)^2 - 3*B*a*tan(d*x)*tan(c)^3 - 3*A*b*tan(d*x)*t 
an(c)^3 + 2*B*b*tan(d*x)^3 - 9*B*a*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x) 
*tan(c) + 1)/(tan(d*x)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)*t 
an(c) - 9*A*b*log(4*(tan(d*x)^2*tan(c)^2 - 2*tan(d*x)*tan(c) + 1)/(tan(d*x 
)^2*tan(c)^2 + tan(d*x)^2 + tan(c)^2 + 1))*tan(d*x)*tan(c) - 12*A*a*tan(d* 
x)^2*tan(c) + 18*B*b*tan(d*x)^2*tan(c) - 12*A*a*tan(d*x)*tan(c)^2 + 18*B*b 
*tan(d*x)*tan(c)^2 + 2*B*b*tan(c)^3 - 6*A*a*d*x + 6*B*b*d*x + 3*B*a*tan...
 
3.3.32.9 Mupad [B] (verification not implemented)

Time = 7.28 (sec) , antiderivative size = 84, normalized size of antiderivative = 0.97 \[ \int \tan ^2(c+d x) (a+b \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (A\,a-B\,b\right )-\ln \left ({\mathrm {tan}\left (c+d\,x\right )}^2+1\right )\,\left (\frac {A\,b}{2}+\frac {B\,a}{2}\right )+{\mathrm {tan}\left (c+d\,x\right )}^2\,\left (\frac {A\,b}{2}+\frac {B\,a}{2}\right )-d\,x\,\left (A\,a-B\,b\right )+\frac {B\,b\,{\mathrm {tan}\left (c+d\,x\right )}^3}{3}}{d} \]

input
int(tan(c + d*x)^2*(A + B*tan(c + d*x))*(a + b*tan(c + d*x)),x)
 
output
(tan(c + d*x)*(A*a - B*b) - log(tan(c + d*x)^2 + 1)*((A*b)/2 + (B*a)/2) + 
tan(c + d*x)^2*((A*b)/2 + (B*a)/2) - d*x*(A*a - B*b) + (B*b*tan(c + d*x)^3 
)/3)/d